package thread;

/**
 * 静态方法锁
 */
public class SyncDemo3 {
    public static void main(String[] args) {
        Aoo a1 = new Aoo();
        Aoo a2 = new Aoo();
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                a1.dosome();
            }
        };
        Thread t2 = new Thread("t2") {
            @Override
            public void run() {
                a2.dosome();
            }
        };
        t1.start();
        t2.start();
    }
}

class Aoo {
    public static void dosome() {
        synchronized (Aoo.class) {
            Thread t = Thread.currentThread();
            System.out.println(t.getName() + " 这个线程正在执行dosome方法");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
            System.out.println(t.getName() + " 这个线程执行dosome方法完毕");
        }
    }
}